package com.winbomb.simulife.game.screens;

import com.winbomb.simulife.Girl;
import com.winbomb.simulife.Master;
import com.winbomb.simulife.framework.Game;
import com.winbomb.simulife.framework.Screen;
import com.winbomb.simulife.framework.Input.TouchEvent;
import com.winbomb.simulife.game.Assets;
import com.winbomb.simulife.game.GameScreen;
import com.winbomb.simulife.game.TouchArea;
import com.winbomb.simulife.impl.GirlFactory;

public class FindGirlScreen extends Screen {

	final TouchArea okArea = new TouchArea(10, 445, 140, 23);
	final TouchArea cancelArea = new TouchArea(165, 445, 140, 23);

	Girl girl;

	public FindGirlScreen(Game game) {
		super(game);

		GirlFactory girlFactory = new GirlFactory(game.getWorld());
		girl = girlFactory.newGirl();
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void present(float deltaTime) {
		g.drawPixmap(Assets.find_girl, 0, 0);

		g.drawText(girl.getName(), 210, 35);
		g.drawText(String.valueOf(girl.getAge()), 210, 60);
		g.drawText(String.valueOf(girl.getBeauty()), 210, 85);
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(float deltaTime) {
		updateTouchEvents();

		for (TouchEvent event : touchEvents) {
			if (event.type != TouchEvent.TOUCH_UP) {
				continue;
			}

			if (okArea.isBound(event)) {
				Master master = game.getWorld().getMaster();
				if (girl.accept(master)) {
					master.setGirl(girl);
				}
			} else if (cancelArea.isBound(event)) {
				game.setScreen(new GameScreen(game));
			}
		}

	}

}
